
@rem======================================================================
@rem
@rem    "kiiro.sign.binary.bat"
@rem
@rem======================================================================

@echo off

goto LInitialize


@rem----------------------------------------------------------------------
@rem    LInitialize -- Set Variables
@rem----------------------------------------------------------------------
:LInitialize
	set signtool="../../Kiiro.Tools/signtool/signtool.exe"
	set certificate="../../Kiiro.Tools/signtool/nFormCodeSignCert.pfx"
	set keypw=nForm2008CodeSign
	set timestampservice="http://timestamp.verisign.com/scripts/timstamp.dll"

	set filePath="../../Kiiro.MSProjectPluginSetup/Debug/KiiroMSProjectPlugin1.2.0.1.exe"

    goto LParseArgs


@rem----------------------------------------------------------------------
@rem    LParseArgs
@rem----------------------------------------------------------------------
:LParseArgs
	@rem --- Fix filePath ---
    if "%1" == "/filePath"  (set filePath=%2)  & shift & shift & goto LParseArgs
    if "%1" == "-filePath"  (set filePath=%2)  & shift & shift & goto LParseArgs
    
    @rem --- Check arguments ---
	if not "%filePath%" == "" (
		set filePath=%filePath%
		echo.
		echo Setting filePath to be %filePath%
	)
    if "%filePath%" == "" (
        echo.
		echo No filePath set
@rem        exit 1
    )
    
	goto LMain


@rem----------------------------------------------------------------------
@rem    LMain
@rem----------------------------------------------------------------------
:LMain
	
	call :LSignBinary
	
	goto LTerminate


@rem----------------------------------------------------------------------
@rem	LSignBinary
@rem----------------------------------------------------------------------
:LSignBinary

	%signtool% sign /t %timestampservice% /f %certificate% /p %keypw% %filePath%
	
    goto :EOF


@rem----------------------------------------------------------------------
@rem    LTerminate
@rem----------------------------------------------------------------------
:LTerminate
	set signtool=
	set certificate=
	set keypw=
	set timestampservice=

	set filePath=